package com.erdos.core.dao.ibatis;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.erdos.common.dao.IBatisGenericDaoImpl;
import com.erdos.core.dao.AttributeDao;
import com.erdos.core.entity.Attribute;
import com.erdos.core.entity.AttributeValue;

public class AttributeDaoImpl extends IBatisGenericDaoImpl<Attribute>implements AttributeDao{

	/**
	 * 查询对象、工厂下已有的Field主键集合
	 * @return
	 */
	public List<Long> findExistFieldSids(Map<String, Object> params) {
		List<Long> list = this.getSqlMapClientTemplate().queryForList("Attribute.findExistFieldSids",params);
		return list;
	}

	/**
	 * 查询工厂列表，用于前端下拉框展示
	 * @return
	 */
	public Map<Long,String> findFacilityMap() {
		Map<Long,String> resultMap =this.getSqlMapClientTemplate().queryForMap("Attribute.findFacilityMap", null, "sid", "facilityId");
		//定义返回为<LabelValueBean>的集合。、
		return resultMap;
	}

	/**
	 * 查询对象、工厂下已有的分组列表
	 * @return
	 */
	public Map<String,String> findGroupMap(Map<String, Object> params) {
		List<String> list = this.getSqlMapClientTemplate().queryForList("Attribute.findGroupMap", params);
		Map<String,String> resultMap = new HashMap<String,String>();
		for(String groupName: list){
			resultMap.put(groupName,groupName);
		}
		return resultMap;
	}

	/**
	 * 查询对象列表，用于前端下拉框展示
	 * @return
	 */
	public Map findObjectMap() {
		Map resultMap = this.getSqlMapClientTemplate().queryForMap("Attribute.findObjectMap", null,"attributeGroup","attributeGroup");
		return resultMap;
	}

	/* (non-Javadoc)
	 * @see com.hp.core.dao.AttributeDAO#findAttributeCount(java.util.Map)
	 */
	public int findAttributeCount(Map<String, Object> params) {
		List<AttributeValue> attributeValueList = this.getSqlMapClientTemplate().queryForList("Attribute.findAttributeCount",params);
		return attributeValueList.size();
	}
	
}
